<?php

declare(strict_types=1);
/**
 * This file is part of bearing-web.
 *
 * @link     https://www.bearing.cn/
 * @contact  tech@bearing.cn
 * @license  https://gitee.com/cppo/bearing_web/-/blob/master/README.md
 */
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

defined('YII_DEBUG') or define('YII_DEBUG', env('YII_DEBUG') ?: false);
defined('YII_ENV') or define('YII_ENV', env('YII_ENV') ?: 'prod');

function env($key)
{
    $value = getenv($key) ?: ($_ENV[$key] ?? '');

    switch (strtolower($value)) {
        case 'true':
        case '(true)':
            return true;
        case 'false':
        case '(false)':
            return false;
        case 'null':
            return null;
    }

    return $value;
}
